package com.mapper;

import com.javabean.Role;
import com.javabean.RolePermission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: 张波
 * @Time: 2025/8/28 14:31
 */
public interface  RoleMapper {
	/// 角色查询
	@Select("select * from project.role")
	List<Role> selectAll();
	/// 根据id查询角色详细
	Role selectR_P(int id);
	/// 添加角色
	@Insert("insert into project.role (roleName, roleDesc) values (#{roleName},#{roleDesc})")
	int insertRole(Role role);
	/// 根据id删除角色
	@Delete("delete from project.role where id=#{id}")
	int deleteRole(int id);

	// TODO批量删除
	int deleteByList(List<Integer> ids);
	/// 角色权限修改权限名称和描述 先使用的是根据id进行查询 之后根据id进行修改,返回被修改的新对象
	@Update("update project.role set roleName=#{roleName},roleDesc=#{roleDesc}  where id=#{id}")
	int updateByRid(Role role);

	@Delete("delete from role_permission where roleId=#{rid}")
	int deleteByRid(int rid);


	int insertR_P(RolePermission rolePermission);
}
